﻿/*
 * Created by SharpDevelop.
 * User: issuser
 * Date: 2010-12-9
 * Time: 15:00
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Data.Common;
using NLite.Reflection;
using System.Data;

namespace NLite.Data.Driver
{
	/// <summary>
	/// Description of ReflectionBasedDriver.
	/// </summary>
	public abstract class ReflectionBasedDriver:DriverBase
	{
	

        protected readonly IClassLoader classLoader;
        protected  readonly Type connectionType;

        protected ReflectionBasedDriver(string connectionTypeName)
		{
            classLoader = ServiceLocator.Get<IClassLoader>();

			connectionType = classLoader.LoadType(connectionTypeName);
			if (connectionType == null )
                throw new DAOException("");
		}


        protected override DbConnection InternalCreateConnection()
        {
            return classLoader.NewInstance(connectionType) as DbConnection;
        }
    }
}
